import * as type from '../mutation-type'

const initState = {
  coupon_templates: [],
  campaigns: [],
  coupons: [],

  coupon: {
    id: null,
    product_id: null,
    code: null,           
    name: null, 
    number: null,   
    channel: null,               
    number: null,           
    price: null,              
    valid_before: null,      
    valid_after: null,       
    limit_state: null,     
    kind: null,      
    quota: null,
    validing: null,
    geting: null,
    using: null,
  },

  coupon_template: {
    name: null,
    description: null,
    price: null,  // 价格
    valid_before: null, // 有效期右边值
    valid_after: null, // 有效期左边值
    related_expire: null    // 相对有效期，单位秒
  },
  campaign: {
    name: null,
    description: null,
    category: 'campaign', // 新注册 new_user，活动页 campaign
    coupon_template: {
      id: null,
    },
    activated: false, // 有效
    valid_before: null, // 有效期右边值
    valid_after: null // 有效期左边值
  }
}

const state = _.cloneDeep(initState)

const mutations = {
  // 列表
  [type.GET_COUPONS] (state, {coupons,coupon_templates, campaigns}) {
    state.coupon_templates = coupon_templates
    state.campaigns = campaigns
    state.coupons = coupons
  },
}

export default {
  state,
  mutations
}
